home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
wxmodem.zip
/
WXMOXFER.INC
< prev
Wrap
Text File
|
1986-11-06
|
40KB
|
1,006 lines
{$U-,C-,R-,K-}
{ - modified to add CRC xmodem, wxmodem 7/86 - 10/86
Peter Boswell
ADI
Suite 650
350 N. Clark St.
Chicago, Il 60610
People/Link: Topper
Compuserve : 72247,3671
}
const
SOH = 1; {Start Of Header}
EOT = 4; {End Of Transmission}
ACK = 6; {ACKnowledge}
DLE = $10; {Data Link Escape}
XON = $11; {X-On}
XOFF = $13; {X-Off}
NAK = $15; {Negative AcKnowledge}
SYN = $16; {Synchronize}
CAN = $18; {CANcel}
CHARC = $43; {C = CRC Xmodem}
CHARW = $57; {W = WXmodem}
MAXERRS = 10; {Maximum allowed errors}
L = 0;
H = 1;
Buflen = 128; {Disk I/O buffer length}
Bufnum = 64; {Disk I/O buffer count}
Maxwindow = 4; {Wxmodem window size}
{CRC byte translation table}
Crctab: array[0..255] of Integer =
(0, 4129, 8258, 12387, 16516, 20645, 24774, 28903,
-32504,-28375,-24246,-20117,-15988,-11859,-7730,-3601,
4657, 528, 12915, 8786, 21173, 17044, 29431, 25302,
-27847,-31976,-19589,-23718,-11331,-15460,-3073,-7202,
9314, 13379, 1056, 5121, 25830, 29895, 17572, 21637,
-23190,-19125,-31448,-27383,-6674,-2609,-14932,-10867,
13907, 9842, 5649, 1584, 30423, 26358, 22165, 18100,
-18597,-22662,-26855,-30920,-2081,-6146,-10339,-14404,
18628, 22757, 26758, 30887, 2112, 6241, 10242, 14371,
-13876,-9747,-5746,-1617,-30392,-26263,-22262,-18133,
23285, 19156, 31415, 27286, 6769, 2640, 14899, 10770,
-9219,-13348,-1089,-5218,-25735,-29864,-17605,-21734,
27814, 31879, 19684, 23749, 11298, 15363, 3168, 7233,
-4690,-625,-12820,-8755,-21206,-17141,-29336,-25271,
32407, 28342, 24277, 20212, 15891, 11826, 7761, 3696,
-97,-4162,-8227,-12292,-16613,-20678,-24743,-28808,
-28280,-32343,-20022,-24085,-12020,-16083,-3762,-7825,
4224, 161, 12482, 8419, 20484, 16421, 28742, 24679,
-31815,-27752,-23557,-19494,-15555,-11492,-7297,-3234,
689, 4752, 8947, 13010, 16949, 21012, 25207, 29270,
-18966,-23093,-27224,-31351,-2706,-6833,-10964,-15091,
13538, 9411, 5280, 1153, 29798, 25671, 21540, 17413,
-22565,-18438,-30823,-26696,-6305,-2178,-14563,-10436,
9939, 14066, 1681, 5808, 26199, 30326, 17941, 22068,
-9908,-13971,-1778,-5841,-26168,-30231,-18038,-22101,
22596, 18533, 30726, 26663, 6336, 2273, 14466, 10403,
-13443,-9380,-5313,-1250,-29703,-25640,-21573,-17510,
19061, 23124, 27191, 31254, 2801, 6864, 10931, 14994,
-722,-4849,-8852,-12979,-16982,-21109,-25112,-29239,
31782, 27655, 23652, 19525, 15522, 11395, 7392, 3265,
-4321,-194,-12451,-8324,-20581,-16454,-28711,-24584,
28183, 32310, 20053, 24180, 11923, 16050, 3793, 7920);
{*** variables used as globals in this source segment
(actually global to whole source) ***}
var
checksum : integer;
tblks : integer;
fname : bigstring;
response : string[1];
crcval,db,sb : integer;
packetln : integer; {128 + Checksum or 128 + CRC}
p : parity_set;
dbuffer : array[1..Bufnum,1..Buflen] of byte;
dcount : integer;
Wxmode : boolean;
Crcmode : boolean;
Openflag : boolean;
Windowfl : boolean;
procedure updcrc(a : byte);
begin
{
crcval := Crctab[hi(crcval) xor a] xor (lo(crcval) shl 8);
}
inline(
$A1/crcval/ {mov ax,crcval AX <- crcval}
$89/$C2/ {mov dx,ax DX <- crcval}
$88/$E0/ {mov al,ah (AX) crcval >> 8}
$B4/$00/ {mov ah,0 }
$36/ {ss:}
$8B/$8E/a/ {mov cx,[bp+a] CX <- a}
$31/$C8/ {xor ax,cx AX <- (crcval >> 8) xor a}
$D1/$E0/ {shl ax,1 AX <- AX * 2 (word index)}
$BB/crctab/ {mov bx,offset crctab BX <- addr(crctab)}
$01/$C3/ {add bx,ax BX <- addr(crctab)+((crcval>>8)xor a)*2 }
$2E/ {cs:}
$8B/07/ {mov ax,[bx] AX <- contents of crctab}
$88/$D6/ {mov dh,dl (DX) crcval << 8}
$B2/$00/ {mov dl,00}
$31/$D0/ {xor ax,dx AX <- contents of crctab xor crcval << 8}
$A3/crcval {mov crcval,ax crcval <- AX}
);
end;
{ Xmodem transmit window routine
Peter Boswell, July 1986 }
procedure txwindow(opt : integer; in_string : bigstring);
begin
if not displayfl then
exit;
case opt of
1 : begin {initialize}
OpenTemp(36,3,78,18,2);
Windowfl := true;
Clrscr;
GotoXY(10,1);
write('File - ',in_string);
GotoXY(10,2);
write('Mode -');
GotoXY(4,3);
write('Total time -');
GotoXY(2,4);
write('Total Blocks -');
GotoXY(10,5);
write('Sent -');
GotoXY(9,6);
write('ACK''d -');
GotoXY(6,7);
write('Last NAK -');
GotoXY(9,8);
write('X-Off - No');
GotoXY(8,9);
write('Window - 0');
GotoXY(4,11);
write('Last Error -');
GotoXY(8,10);
write('Errors -');
end;
2..11 : begin
GotoXY(17,opt);
ClrEol;
write(in_string);
end;
12 : begin
GotoXY(3,12);
ClrEol;
write(in_string);
end;
99 : begin
if windowfl then
CloseTemp;
end;
end; {case}
end;
{ Xmodem receive window routine
Peter Boswell, October 1986 }
procedure trwindow(opt : integer; in_string : bigstring);
begin
if not displayfl then
exit;
case opt of
1 : begin {initialize}
windowfl := true;
OpenTemp(36,3,78,13,2);
Clrscr;
GotoXY(10,1);
write('File - ',in_string);
GotoXY(10,2);
write('Mode -');
GotoXY(6,3);
write('Received -');
GotoXY(6,4);
write('Last NAK -');
GotoXY(4,5);
write('Last Error -');
GotoXY(8,6);
write('Errors -');
end;
2..6 : begin
GotoXY(17,opt);
ClrEol;
write(in_string);
end;
8 : begin
GotoXY(3,8);
ClrEol;
write(in_string);
end;
99 : begin
if windowfl then
CloseTemp;
end;
end; {case}
end;
{
This routine deletes all DLE characters and XOR's the following character
with 64. If a SYN character is found then -2 is returned.
}
function dlecgetc(Tlimit : integer) : integer;
var
savecgetc : integer;
begin
if wxmode then
begin
savecgetc := cgetc(Tlimit);
if savecgetc = SYN then
savecgetc := -2
else